<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>

<!DOCTYPE html>
<html>
	<head>
		<title>编辑角色</title>
		<meta name="decorator" content="default"/>
		<script type="text/javascript">
			$(function() {
				//初始化表单验证
				$("#inputForm").initValidform();
				//是否启用权限
		        if ($("#ddlRoleType").find("option:selected").attr("value") == 1) {
		            $(".border-table").find("input[type='checkbox']").prop("disabled", true);
		        }
		        $("#ddlRoleType").change(function () {
		            if ($(this).find("option:selected").attr("value") == 1) {
		                $(".border-table").find("input[type='checkbox']").prop("checked", false);
		                $(".border-table").find("input[type='checkbox']").prop("disabled", true);
		            } else {
		                $(".border-table").find("input[type='checkbox']").prop("disabled", false);
		            }
		        });
		        //权限全选
		        $("input[name='checkAll']").click(function () {
		            if ($(this).prop("checked") == true) {
		                $(this).parent().siblings("td").find("input[type='checkbox']").prop("checked", true);
		            } else {
		                $(this).parent().siblings("td").find("input[type='checkbox']").prop("checked", false);
		            }
		        });
			});
		</script>
	</head>
	
	<body class="mainbody">
		<sys:message content="${message}"/>
		
		<form:form id="inputForm" modelAttribute="role" action="${ctx}/sys/role/save" method="post" class="form-horizontal">
			<form:hidden path="id"/>
			<!--导航栏-->
			<div class="location">
				<a href="${ctx}/sys/role/list" class="back"><i></i><span>返回列表页</span></a>
				<a href="${ctx}/center" class="home"><i></i><span>首页</span></a> 
				<i class="arrow"></i> 
				<a href="${ctx}/sys/role/"><span>角色</span></a>
				<shiro:hasPermission name="sys:role:edit"><i class="arrow"></i><span>${not empty role.id ? '修改':'添加' }角色</span></shiro:hasPermission>
			</div>	
			<div class="line10"></div>
			<!--/导航栏-->
	
			<!--内容-->
			<div id="floatHead" class="content-tab-wrap">
				<div class="content-tab">
					<div class="content-tab-ul-wrap">
						<ul>
							<li><a class="selected" href="javascript:;">角色信息</a></li>
						</ul>
					</div>
				</div>
			</div>
	
			<div class="tab-content">
				<dl>
					<dt>角色名称</dt>
					<dd>
						<form:input path="name" htmlEscape="false" maxlength="50" class="required" cssClass="input normal" datatype="*" nullmsg="请输入角色名称" errormsg="请输入角色名称" sucmsg=" "/>
						<span class="Validform_checktip">*角色中文名称，100字符内</span>
					</dd>
				</dl>
				<dl> 
					<dt>英文名称</dt>
					<dd>
						<form:input path="enname" htmlEscape="false" maxlength="50" class="required" cssClass="input normal" datatype="*" nullmsg="请输入英文名称" errormsg="请输入英文名称" sucmsg=" "/>
						<span class="Validform_checktip">*角色英文名称，100字符内</span>
					</dd>
				</dl>
				<dl>
					<dt>是否可用</dt>
					<dd>
						<div class="rule-multi-radio">
							<form:radiobuttons path="useable" items="${fns:getDictList('yesno')}" itemLabel="label" itemValue="value" htmlEscape="false" class="required"/>
							<%-- <form:checkbox path="isShow" value="0" htmlEscape="false" maxlength="50" class="required" cssClass="input normal" datatype="*" nullmsg="请输入是否在菜单中显示（1：显示；0：不显示）" errormsg="请输入是否在菜单中显示（1：显示；0：不显示）" sucmsg=" "/> --%>
						</div>
						<span class="Validform_checktip"></span>
					</dd>
				</dl>
				<dl>
					<dt>备注信息</dt>
					<dd>
						<form:textarea rows="5" path="remarks" htmlEscape="false" cssClass="input normal"  maxlength="50"/>
						<span class="Validform_checktip"></span>
					</dd>
				</dl>
				<dl>
				    <dt>管理权限</dt>
				    <dd>
				    	<table class="border-table" style="width:98%;">
							<thead>
								<tr>
									<th width="30%">名称</th>
									<th>权限分配</th>
									<th width="10%">全选</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${menuList}" var="menu">
								<tr>
									<td>
										<span style="display:inline-block;width:${(menu.layer - 1) * 24}px;"></span>
										<span class="folder-line"></span>
										<span class="folder-open"></span>
										${menu.name} 
										</td>
									<td>
										<span class="cbllist">
											<c:forEach items="${menu.permissions}" var="perm">
												<input type="checkbox" name="cb_${menu.id}" <c:if test="${perm.checked}">checked="checked"</c:if> value="${perm.permissions }">
												<label for="cb_${menu.id}">${perm.permName }</label>
											</c:forEach>
										</span>
									</td>	
									<td align="center"><input name="checkAll" type="checkbox" /></td>
								</tr>
								</c:forEach>
							</tbody>
						</table>
				    </dd>
				</dl>
			</div>
			<!--/内容-->
	
			<!--工具栏-->
			<div class="page-footer">
				<div class="btn-wrap">
					<input type="submit" name="btnSubmit" value="提交保存" id="btnSubmit" class="btn" /> 
					<input name="btnReturn" type="button" value="返回上一页" class="btn yellow" onclick="javascript:history.back(-1);" />
				</div>
			</div>
			<!--/工具栏-->
		</form:form>
	</body>
</html>

